/*
* This file is a part of the open-eBackup project.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright (c) [2024] Huawei Technologies Co.,Ltd.
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*/
#include "log/Log.h"
#include "FusionStorageApiFactory.h"

VIRT_PLUGIN_NAMESPACE_BEGIN

FusionStorageApiFactory *FusionStorageApiFactory::GetInstance()
{
    DBGLOG("FusionStorageApi job factory instance.");
    static FusionStorageApiFactory instance;
    return &instance;
}

FusionStorageApiFactory::FusionStorageApiFactory()
{}

FusionStorageApiFactory::~FusionStorageApiFactory()
{}

std::shared_ptr<FusionStorageApi> FusionStorageApiFactory::CreateFusionStorageApi(
    const std::string &apiMode, const std::string &fusionStorMgrIp, const std::string &poolID)
{
    std::shared_ptr<FusionStorageApi> retValuePtr = nullptr;

    if (apiMode == "VBS") {
        retValuePtr = std::make_shared<FusionStorageApi>(fusionStorMgrIp, poolID);
    } else if (apiMode == "ISCSI") {
        retValuePtr = std::make_shared<FusionStorageRestApiOperator>(fusionStorMgrIp, poolID, "", "");
    } else {
        WARNLOG("Create FusionStorageApi failed.");
        return nullptr;
    }

    return retValuePtr;
}

VIRT_PLUGIN_NAMESPACE_END  // namespace VirtPlugin
